var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (o, t) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, o) {
              e.__proto__ = o;
            }) ||
          function (e, o) {
            for (var t in o)
              Object.prototype.hasOwnProperty.call(o, t) && (e[t] = o[t]);
          })(o, t);
      };
      return function (o, t) {
        function l() {
          this.constructor = o;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        e(o, t),
          (o.prototype =
            null === t
              ? Object.create(t)
              : ((l.prototype = t.prototype), new l()));
      };
    })(),
  RoleManageView = (function (e) {
    function o(o) {
      var t = e.call(this) || this;
      return (
        (t.onLoadDeleteRoleAction = {
          caller: t,
          code: 1475,
          method: function (e) {
            ToastView.toastView(e.msg),
              "0" == e.code &&
                (t.roleList.splice(t.list_roleManager.selectedIndex, 1),
                t.showRoleItemData()),
              WebSocketService.send({ c: 3, d: null });
          },
        }),
        t.btn_roleCancle.on(Laya.Event.CLICK, t, t.onRoleBackPreFn),
        (t.list_roleManager.vScrollBarSkin = ""),
        (t.list_roleManager.selectEnable = !0),
        t.list_roleManager.on(Laya.Event.CLICK, t, t.onDidClickRoleManagerFn),
        (t.list_roleManager.renderHandler = new Handler(t, t.onListRenderCell)),
        WebSocketService.addListener(t.onLoadDeleteRoleAction),
        WebSocketService.addListener({
          caller: t,
          code: 5314,
          method: t.onLoadRoleManager,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 3,
          method: t.loadRoleDataMsgFn,
        }),
        t
      );
    }
    return (
      __extends(o, e),
      (o.openRoleManagerView = function (e) {
        return (
          null == this.roleManagerVC && (this.roleManagerVC = new o(e)),
          (this.roleManagerVC.roleList = e),
          (this.roleManagerVC.deleteRoleArr = []),
          this.roleManagerVC.showRoleItemData(),
          this.roleManagerVC
        );
      }),
      (o.prototype.showRoleItemData = function () {
        for (var e, o = [], t = 0; t < this.roleList.length; t++)
          (e = {
            role_headImg: {
              skin:
                "comp/hreoImg/ws" +
                this.setRoleImage(
                  this.roleList[t].roleType,
                  this.roleList[t].sex
                ) +
                ".png",
            },
            role_name: { text: this.roleList[t].name },
            role_descr: { text: "等级 : " + this.roleList[t].lvl },
            role_ID: { text: "ID : " + this.roleList[t].id },
            role_to_sale: {
              label: this.dealRoleSaleState(this.roleList[t].allowLogin),
            },
            role_delete: { label: "删除" },
            allowLogin: this.roleList[t].allowLogin,
            id: this.roleList[t].id,
          }),
            o.push(e);
        this.list_roleManager.dataSource = o;
      }),
      (o.prototype.dealRoleSaleState = function (e) {
        return 6 == e ? "已上架" : 7 == e ? "有人要" : "出售";
      }),
      (o.prototype.onDidClickRoleManagerFn = function (e) {
        if ("" != e.target.name)
          if ("role_delete" == e.target.name)
            NormalDialog.showNormalDialog(
              "确定删除该角色?",
              this,
              this.okMethodFunction
            );
          else if ("role_to_sale" == e.target.name) {
            var o = this.list_roleManager.selectedItem;
            6 == o.allowLogin
              ? NormalDialog.showNormalDialog(
                  "确定取消寄售？",
                  this,
                  this.onCancleSaleAction
                )
              : 7 == o.allowLogin
              ? CommonUIDialog.showCommonUIDialog(o, "accountRole")
              : NormalNewDialog.showNewNormalDialog(
                  "温馨提示",
                  "1.出售角色需达到VIP3，并身上携带有3000金币作为手续费\n2.角色出售过程中将暂时封禁\n3.其他玩家可在当铺看到出售的角色信息\n4.24小事玩家无人购买将自动终止出售\n5.角色交易过程中，需玩家自行斟酌，官方不参与其中",
                  this,
                  this.okSaleMethodFunction
                );
          }
      }),
      (o.prototype.onCancleSaleAction = function () {
        var e = this.list_roleManager.selectedItem;
        WebSocketService.send({ c: 5314, d: { roleId: e.id, type: 2 } });
      }),
      (o.prototype.okMethodFunction = function () {
        (this.deleteRoleID =
          this.roleList[this.list_roleManager.selectedIndex].id),
          WebSocketService.send({
            c: 1475,
            d: { roleid: this.deleteRoleID, pwd: "" },
          });
      }),
      (o.prototype.okSaleMethodFunction = function () {
        var e = this.roleList[this.list_roleManager.selectedIndex].id;
        WebSocketService.send({ c: 5314, d: { roleId: e, type: 1 } });
      }),
      (o.prototype.setRoleImage = function (e, o) {
        return "2" == e
          ? "0" == o
            ? 5
            : 2
          : "1" == e
          ? "0" == o
            ? 4
            : 1
          : "3" == e
          ? "0" == o
            ? 6
            : 3
          : 0;
      }),
      (o.prototype.onListRenderCell = function (e, o) {
        var t = e.getChildByName("role_to_sale"),
          l = e.dataSource;
        6 == l.allowLogin
          ? (t.label = "出售中")
          : 7 == l.allowLogin
          ? (t.label = "有人要")
          : (t.label = "出售");
      }),
      (o.prototype.onLoadRoleManager = function (e) {
        ToastView.toastView(e.msg),
          WebSocketService.send({ c: 3, d: null }),
          this.refreshItemCell();
      }),
      (o.prototype.refreshItemCell = function () {
        6 == this.list_roleManager.selectedItem.allowLogin
          ? (this.roleList[this.list_roleManager.selectedIndex].allowLogin =
              "1")
          : (this.roleList[this.list_roleManager.selectedIndex].allowLogin =
              "6"),
          this.showRoleItemData();
      }),
      (o.prototype.loadRoleDataMsgFn = function (e) {}),
      (o.prototype.onRoleBackPreFn = function () {
        this.removeSelf();
      }),
      o
    );
  })(ui.LoginManager.RoleManageViewUI);
